package com.mentaleye.biz.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mentaleye.bean.RolePersonBean;
import com.mentaleye.biz.RolePersonBiz;
import com.mentaleye.service.RolePersonService;
import com.mentaleye.util.CommonPage;
import com.mentaleye.util.CommonResult;
@Service
public class RolePersonBizImpl implements RolePersonBiz{

	@Autowired private RolePersonService rolePersonService;
	private static Logger logger = Logger.getLogger(RolePersonBizImpl.class);
	@Override
	public CommonResult addRolePerson(RolePersonBean rolePersonBean) {
		try {
			return new CommonResult(rolePersonService.addRolePerson(rolePersonBean));
		} catch (Exception e) {
			logger.error("添加角色关联人员异常", e);
			return new CommonResult();
		}
		
	}

	@Override
	public CommonResult dropRolePersonByPersonNo(Integer personNo,Integer roleNo,Integer personType) {
		try {
			return new CommonResult(rolePersonService.deleteRolePersonById(personNo,roleNo,personType));
		} catch (Exception e) {
			logger.error("删除角色关联人员异常", e);
			return new CommonResult();
		}
	}

	@Override
	public CommonResult dropRolePersonByPersonList(List<Integer> ids,Integer roleNo) {
		try {
			return new CommonResult(rolePersonService.deleteRolePersonByList(ids,roleNo));
		} catch (Exception e) {
			logger.error("删除角色关联人员列表异常", e);
			return new CommonResult();
		}
	}

	@Override
	public List<RolePersonBean> getRolePerson(Integer roleNo) {
		try {
			return rolePersonService.selectRolePerson(roleNo);
		} catch (Exception e) {
			logger.error("根据角色查询角色关联人员异常", e);
			return null;
		}
	}

	@Override
	public void queryRolePersonByPage(CommonPage commonPage) {
		try {
			rolePersonService.queryRoleTeacherByPage(commonPage);
		} catch (Exception e) {
			logger.error("分页查询人员异常", e);
		}
		
	}

	@Override
	public CommonResult addRolePersonList(List<RolePersonBean> rolePersonBeanList) {
		try {
			return new CommonResult(rolePersonService.addRolePersonList(rolePersonBeanList));
		} catch (Exception e) {
			logger.error("批量添加角色关联人员异常", e);
			return new CommonResult();
		}
	}

}
